//
//  BiIndexSaleViewController.m
//  TrunkIndustryManageSystem
//
//  Created by WT_lyy on 15/4/20.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "BiIndexSaleViewController.h"
#import "BiSaleApplyViewController.h"
#import "BiSaleListViewController.h"


#import "BiSaleApplyManageViewController.h"
#import "BiCustomerInfoViewController.h"
#import "BiSaleExecuteCheckViewController.h"

@interface BiIndexSaleViewController ()

@end

@implementation BiIndexSaleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSDictionary * imageDic = [NSDictionary dictionaryWithObjectsAndKeys:@"common/icon_liebiao",@"applysell",
                               @"common/icon_zhixing",@"checksell",
                               @"common/icon_shenpi",@"runsell",
                               @"common/icon_hetong",@"contractcomplete",
                               @"common/icon_jiaojie",@"carhandover",nil];
    
   
    NSDictionary * titleDic = [NSDictionary dictionaryWithObjectsAndKeys:@"行销申请",@"applysell",
                               @"行销审批",@"checksell",
                               @"行销执行",@"runsell",
                               @"合同完成",@"contractcomplete",
                               @"车辆交接",@"carhandover",nil];
    
    
    
    NSMutableArray * imagearr = [NSMutableArray array];
    NSMutableArray * titlearr = [NSMutableArray array];
    NSArray * saleArr = [BiUserEntity sharedInstance].permissionDic[@"zhengchexingxiao"];
    
    for (int i =0 ; i < saleArr.count; i++) {
        NSString * saleStr = saleArr[i];
        
        [imagearr addObject:imageDic[saleStr]];
        
        [titlearr addObject:titleDic[saleStr]];
    }
    
    
    [self refreshTable:titlearr imageArr:imagearr title:@"整车销售"];
    
    

}


#pragma -mark UitabeViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    UITableViewCell * cell  = [tableView cellForRowAtIndexPath:indexPath];
    
    UILabel * tltlelab = (UILabel *)[cell viewWithTag:2];
    
    BiSaleListViewController  * viewCtrl = [[BiSaleListViewController alloc] init];
    
    if (tltlelab.text.hash == @"行销申请".hash) {
        
        viewCtrl.type = 1;
    }
    else  if (tltlelab.text.hash == @"行销审批".hash) {
        
        viewCtrl.type = 2;
    }
    else  if (tltlelab.text.hash == @"行销执行".hash) {
        
        viewCtrl.type = 3;
    }
    else  if (tltlelab.text.hash == @"合同完成".hash) {
        
        viewCtrl.type = 4;
    }
    else  if (tltlelab.text.hash == @"车辆交接".hash) {
        
        viewCtrl.type = 5;
    }

    [self.navigationController pushViewController:viewCtrl animated:YES];
}



@end
